﻿using IBll;
using IDal;
using Model.DTO;
using Model.House;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bll
{
    public class HouseBll : IHouselBll
    {
        private readonly IHouseDal dal;

        public HouseBll(IHouseDal dal)
        {
            this.dal = dal;
        }
        /// <summary>
        /// 获取酒店类型表数据
        /// </summary>
        /// <returns>获取酒店类型表数据</returns>
        public IQueryable<HotelType> ShowHotelType()
        {
            return dal.ShowHotelType();
        }
        ///显示酒店信息+通过酒店类型查询+分页
        /// </summary>
        /// <param name="typeid">酒店类型</param>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页显示的条数</param>
        /// <returns>通过条件查询和分页显示的当前数据</returns>
        public dynamic ShowHotel(int? typeid = -1, int pageindex = 1, int pagesize = 3)
        {
            return dal.ShowHotel(typeid, pageindex, pagesize);
        }
        /// <summary>
        /// 百度地图
        /// </summary>
        /// <param name="id">通过主键获取到整体数据</param>
        /// <returns>获取经度纬度</returns>
        public Hotel FindHotel(int id)
        {
            return dal.FindHotel(id);
        }

        /// <summary>
        /// 通过选酒店的房间+显示+查询+分页
        /// </summary>
        /// <param name="hotelid">酒店id不可为空</param>
        /// <param name="min">面积最小值</param>
        /// <param name="max">面积最大值</param>
        /// <param name="typeid">房型id</param>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页显示的条数</param>
        /// <returns>通过条件查询和分页显示当前页面的数据</returns>
        public dynamic ShowHouse(int hotelid, decimal? min, decimal? max, int? typeid = -1, int pageindex = 1, int pagesize = 3)
        {
            return dal.ShowHouse(hotelid, min, max, typeid, pageindex, pagesize);
        }
        /// <summary>
        /// 获取房型表信息
        /// </summary>
        /// <returns>获取房型表信息</returns>
        public IQueryable<HouseType> ShowHouseType()
        {
            return dal.ShowHouseType();
        }
        /// <summary>
        /// 房间
        /// </summary>
        /// <param name="house">房间表</param>
        /// <returns>返回受影响行数</returns>
        public int AddHouse(House house)
        {
            return dal.AddHouse(house);
        }
        /// <summary>
        /// 获取所有酒店信息
        /// </summary>
        /// <returns>获取所有酒店信息</returns>
        public IQueryable<Hotel> ShowHotels()
        {
            return dal.ShowHotels();
        }
        /// <summary>
        /// 通过酒店获取房间信息
        /// </summary>
        /// <param name="hotelid">酒店的id</param>
        /// <returns>通过酒店获取房间信息</returns>
        public IQueryable<House> ShowHouseGetImg(int hotelid)
        {
            return dal.ShowHouseGetImg(hotelid);
        }
        /// <summary>
        /// 获取房间的具体信息
        /// </summary>
        /// <param name="houseid">房间if</param>
        /// <returns>通过主键返回房间的具体信息</returns>
        public HouseDto Bindhouse(int houseid)
        {
            return dal.Bindhouse(houseid);
        }
        /// <summary>
        /// 房间显示
        /// </summary>
        /// <param name="housename">房间名称进行模糊查询</param>
        /// <param name="min">价格最小值</param>
        /// <param name="max">价格最大值</param>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页现实的条数</param>
        /// <returns>通过条件查询个分页显示当前页面展示的数据</returns>
        public dynamic ShowHouseDto(string? housename = "", decimal? min = null, decimal? max = null, int pageindex = 1, int pagesize = 3)
        {
            return dal.ShowHouseDto(housename, min, max, pageindex, pagesize);
        }
        /// <summary>
        /// 通过房间id做的反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HouseShowDto GetHouseId(int id)
        {
            return dal.GetHouseId(id);
        }
    }
}
